<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
	*{
		padding: 0px;
		margin: 0px;
	}
	#out{
		width: 500px;
		height: 300px;
		border: 4px solid blue;
		margin: 200px;
		position: relative;
	}
	#out #in{
		width: 300px;
		height: 100px;
		background: green;
		margin: 30px;
	}
</style>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
	
$(function(){
	// 获得元素相对于可视区域的距离
	// var re = $('#in').offset().top;

	// position经常用来获得定位元素的left和top值
	var re = $('#in').position().top;

	alert(re);
})

</script>
</head>

<body>

<div id="out">
	<div id="in"></div>
</div>


</body>
</html>
